import { nanoid } from 'nanoid'
// 初始化值
const initPersons = [{ id: nanoid(), name: 'tom', age: 18 }]

export default function personReducer(persons = initPersons, action) {
  const { type, data } = action
  console.log(action)
  switch (type) {
    case 'addPerson':
      return [data, ...persons]
    default:
      return persons
  }
}
